package cn.smart.feign.autoconfigure;
import cn.smart.feign.decoder.CustomResponseDecoder;
import cn.smart.feign.properties.DecoderXProperty;
import feign.codec.Decoder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(DecoderXProperty.class)
@ConditionalOnProperty(prefix = "cn.smart.decoderx", name = "enable", havingValue = "true", matchIfMissing = true)
public class FeignDecoderAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(Decoder.class)
    public Decoder customResponseDecoder() {
        return new CustomResponseDecoder();
    }
}
